import allure
from page_object.roncoo_login import RoncooLogin
from page_element.roncoo_power_manage import *
import logging
from utils.timer import sleep


class Recnoo_settlement(RoncooLogin):
    """首页搜索商品后退出登录"""

    def recnoo_yhsettlement(self):
        # 前置条件：已登录
        self.roncoo_login()
        with allure.step(f"点击结算管理"):
            self.click(recnoo.recnoo_jsgl)
            sleep(2)
        with allure.step(f"点击结算记录管理"):
            self.click(recnoo.recnoo_jsjl)
            sleep(1)
        with allure.step(f"点击发起结算按钮"):
            self.click(recnoo.recnoo_fqjsbtn)
            sleep(1)
        with allure.step(f"点击搜索图标"):
            self.click(recnoo.recnoo_sstb)
            sleep(1)
        with allure.step(f"选择用户名"):
            self.click(recnoo.recnoo_xz)
            sleep(1)
        with allure.step(f"点击获取可结算余额"):
            self.click(recnoo.recnoo_hqkjsye)
            sleep(1)
        with allure.step(f"输入结算余额"):
            self.send_keys(recnoo.recnoo_jsye, '100')
            sleep(2)
        with allure.step(f"点击提交按钮"):
            self.click(recnoo.recnoo_tjbtn)
            sleep(1)
        with allure.step(f"点击审核"):
            self.click(recnoo.recnoo_sh)
            sleep(1)
        with allure.step(f"输入审核备注"):
            self.send_keys(recnoo.recnoo_shbz, '1')
            sleep(1)
        with allure.step(f"点击提交按钮"):
            self.click(recnoo.recnoo_shbtn)
            sleep(1)
        with allure.step(f"点击打款"):
            self.click(recnoo.recnoo_dk)
            sleep(1)
        with allure.step(f"输入打款备注"):
            self.send_keys(recnoo.recnoo_dkbz, '1')
            sleep(1)
        with allure.step(f"点击提交按钮"):
            self.click(recnoo.recnoo_dkbtn)
            sleep(2)
        with allure.step(f"断言"):
            dy = self.text(recnoo.recnoo_dy)
            assert '打款成功' == dy
